import request from "@/utils/request";
export const getGoodsList = (data) => {
    return request({
        url: '/goods',
        method: 'get',
        params: data
    })
}
export const getCategories = () => {
    return request({
        url: '/categories',
        method: 'get'
    })
}
export const setCategories = (data) => {
    return request({
        url: '/categories',
        method: 'post',
        data
    })
}
export const getGoodsAttribute = (data) => {
    return request({
        url: `/categories/${data.id}/attributes`,
        method: 'get',
        params: {
            sel: data.sel,
        }
    })
}
export const setGoodsAttribute = (data) => {
    return request({
        url: `/categories/${data.id}/attributes`,
        method: 'post',
        data:{
            attr_name:data.attr_name,
            attr_sel:data.attr_sel
        }
    })
}
export const changeGoodsAttribute = (data) => {
    return request({
        url: `/categories/${data.id}/attributes/${data.attr_id}`,
        method: 'put',
        data:{
            attr_name:data.attr_name,
            attr_sel:data.attr_sel
        }
    })
}
export const deleteGoodsAttribute = (data) => {
    return request({
        url: `/categories/${data.id}/attributes/${data.attr_id}`,
        method: 'delete'
    })
}
export const addGoods = (data) => {
    return request({
        url: '/goods',
        method: 'post',
        data
    })
}
export const deleteGoods = (id) => {
    return request({
        url: `/goods/${id}`,
        method: 'delete'
    })
}
export const getOrderList = (data) => {
    return request({
        url: '/orders',
        method: 'get',
        params: data
    })
}
export const getKuaidi = (id) => {
    return request({
        url: `/kuaidi/${id}`,
        method: 'get'
    })
}
export const getTotal = () => {
    return request({
        url: '/reports/type/1',
        method: 'get',
    })
}
export const addAttributes = (data) => {
  return  request({
        url:`/categories/${data.cat_id}/attributes/${data.attr_id}`,
        method:'put',
        data:{
            attr_name:data.attr_name,
            attr_sel:data.attr_sel,
            attr_vals:data.attr_vals
        }
    })
}